<{include file="Public/top.html" }>
</head>
<body>
<div id="warpper">
    <div class="content">
        <div class="location">评论列表</div>
        <div class="filedSet" style="padding-bottom: 0;">
            <div class="search">
                <form action="" id="searchForm" method="get" class="ui-form reportForm">
                    <input name="m" type="hidden" value="<{$module}>">
                    <input name="c" type="hidden" value="<{$controller}>">
                    <input name="a" type="hidden" value="<{$action}>">

                    <input name="p" id="page" type="hidden" value="<{$page|default:1}>">
                    <input name="ofield" id="ofield" type="hidden" value="<{$ofield}>">
                    <input name="otype"  id="otype"  type="hidden" value="<{$otype}>">

                    <div class="ui-form-item inline-block">
                        <label class="ui-label">分类</label>
                        <select name="objType" class="ui-select" style="width: 100px;">
                            <{html_options options=$topicType selected=$objType}>
                        </select>
                    </div>
                    <div class="ui-form-item inline-block">
                        <label class="ui-label">评论人</label>
                        <input type="text" class="ui-text keyword" name="nickname" value="<{$nickName}>"/>
                    </div>
                    <div class="ui-form-item inline-block">
                        <label class="ui-label">关键字</label>
                        <input type="text" value="<{$keyword}>" name="keyword" class="ui-text keyword" placeholder="标题关键字" />
                    </div>

                    <div class="ui-form-item inline-block">
                        <label class="ui-label">编号</label>
                        <input type="text" value="<{$objID}>" name="objID" class="ui-text keyword" placeholder="文章/活动等编号" />
                    </div>

                    <div class="ui-form-item inline-block">
                        <button type="submit" class="ui-button">搜索</button>
                        <button type="button" onclick="exportData();" class="ui-button">导出</button>
                    </div>
                </form>
            </div>
        </div>


        <!--表格内容-->
        <div class="mainGrid">
            <table class="ui-table ui-body">
                <thead>
                <tr>
                    <th class="pct9">分类</th>
                    <th class="pct10">评论人</th>
                    <th class="pct15">评论内容</th>
                    <th class="pct9">评论时间</th>
                    <th class="pct9">点赞数</th>
                    <th class="pct12 last-col">操作</th>
                </tr>
                </thead>
                <tbody>
                <{foreach from=$list item=item}>
                <tr>
                    <td><{$topicType[$item['objType']]}>&nbsp;</td>
                    <td><{$item['nickname']}>&nbsp;</td>
                    <td><{$item['content']}>&nbsp;</td>
                    <td><{$item['addTime']|date_format:'%Y-%m-%d %T'}>&nbsp;</td>
                    <td><{$item['praiseNum']}></td>
                    <td class="ta_l" id="<{$item['id']}>">
                        <div class="handler">
                            <a href="<{u('delete?id='|cat:$item['id']|cat:'&objType='|cat:$item['objType'])}>">删除</a>
                            <span class="sep">|</span>
                            <a href="<{u('disable?id='|cat:$item['id']|cat:'&objType='|cat:$item['objType'])}>">
                                <{if $item['isDisabled']}>取消屏蔽<{else}>屏蔽<{/if}>
                            </a>
                            <span class="sep">|</span>
                            <a href="javascript:void(0)" onclick="reply(<{$item['objID']}>,<{$item['objType']}>,<{$item['id']}>,<{$item['id']}>)">
                                回复
                            </a>
                            <span class="sep">|</span>
                            <{if $item['editorPraiseNum']}>
                                <a href="javascript:void(0)" onclick="cancelPraise(<{$item['id']}>,<{$item['praiseNum']}>,<{$item['editorPraiseNum']}>,<{$item['objType']}>)">取消点赞（<{$item['editorPraiseNum']}>）</a>
                            <{else}>
                                <a id="doPraise" href="javascript:void(0)" onclick="addPraise(<{$item['objType']}>,<{$item['id']}>)">点赞</a>
                            <{/if}>
                        </div>&nbsp;
                    </td>
                </tr>
                <{foreach from=$item['children'] item=child}>
                <tr>
                    <td>子评论</td>
                    <td><{$child['nickname']}></td>
                    <td><{$child['content']}></td>
                    <td><{$child['addTime']|date_format:'%Y-%m-%d %T'}></td>
                    <td><{$child['praiseNum']}></td>
                    <td class="ta_l" id="<{$child['id']}>">
                        <div class="handler">
                            <a href="<{u('delete?id='|cat:$child['id']|cat:'&objType='|cat:$child['objType'])}>">删除</a>
                            <span class="sep">|</span>
                            <a href="<{u('disable?id='|cat:$child['id']|cat:'&objType='|cat:$child['objType'])}>">
                                <{if $child['isDisabled']}>取消屏蔽<{else}>屏蔽<{/if}>
                            </a>
                            <!--<span class="sep">|</span>-->
                            <!--<a href="javascript:void(0)" onclick="reply(<{$item['objID']}>,<{$item['objType']}>,<{$item['id']}>,<{$child['id']}>)">-->
                                <!--回复-->
                            <!--</a>-->
                        </div>
                    </td>
                </tr>
                <{/foreach}>
                <{/foreach}>
                </tbody>
            </table>
        </div>
        <!--描述：分页-->
        <div class="pagination">
            <!--描述：分页-->
            <{include file="Public/page.html" }>
        </div>
    </div>
</div>


<form id="reply" style="display:none">
    <input type="hidden" value="0" name="parentID" id="parentID" />
    <input type="hidden" value="0" name="type" id="objType" />
    <input type="hidden" value="0" name="id" id="objID" />
    <textarea name="content" rows="3" cols="30" id="content" style="width: 99%"></textarea>
    <br />
    <input class="ui-button" type="button" value="提交" id="submitReply"/>
</form>

<form id="praise" style="display: none;">
    <input type="hidden" value="0" name="type" id="objType2" />
    <input type="hidden" value="0" name="id" id="id" />
    <input type="radio" name="praise" checked value="10">10赞</input>
    <input type="radio" name="praise" value="20">20赞</input>
    <input type="radio" name="praise" value="50">50赞</input>
    <br /><br />
    <input class="ui-button" type="button" value="提交" id="submitPraise"/>
    <input class="ui-button" type="button" value="取消" onclick="$('#praise').hide()"/>
</form>

<{include file="Public/foot.html" }>
<script>

    var rep=0;
    function reply(objID,objType,parentID,id){
        $('#objID').val(objID);
        $('#objType').val(objType);
        $('#parentID').val(parentID);
        $('#'+id).append($('#reply').show());
        rep=id;
    }

    function addPraise(objType,id){
        $('#objType2').val(objType);
        $('#id').val(id);
        $('#'+id).append($('#praise').show());
    }
    $(document).ready(
            function(){
                $('#submitReply').on('click',function(){
                    var data=$('#reply').serialize();
                    $.post('<{u("reply")}>',data,function(result){
                        if(result.status==1){
                            $('#reply').hide();
                            $('#'+rep).parent().after("<tr>&nbsp<td><td colspan='4'>回复："+$('#content').val()+"</td></tr>");
                        }else{
                            layer.msg(result.info);
                        }
                    })
                })

                $("#submitPraise").on('click',function(){
                    var param = $("#praise").serialize();
                    $.post('<{U("praise")}>',param,function(result){
                        layer.msg(result.msg);
                        if(result.status == 0){
                            window.location.reload()
                        }

                    })
                })
            }
    );

    //名单导出
    function exportData(){
        if($("#searchForm input[name='objID']").val() == 0){
            layer.msg('请针对一个主体对象导出！');
            return false;
        }
        var exportUri="<{U('comment/export')}>";
        window.location.href = exportUri
                +'&objType='+$("#searchForm select[name='objType']").val()
                +'&nickname='+$("#searchForm input[name='nickname']").val()
                +'&keyword='+$("#searchForm input[name='keyword']").val()
                +'&objID='+$("#searchForm input[name='objID']").val();
    }

    //取消点赞
    function cancelPraise(commentID,praiseNum,editorPraiseNum,objType){
        $.post("<{U('cancelPraise')}>",{commentId:commentID,praiseNum:praiseNum,editorPraiseNum:editorPraiseNum,objType:objType},function(result){
            layer.msg(result.msg);
            if(result.status == 0){
                window.location.reload()
            }
        });
    }

</script>
</body>
</html>
